// 支持支付功能
const app = getApp();
const { reLaunchTo, platformPay, navBack } = require('../../common/platform');
const { PAGE_NAV } = require('../../constants/route');

Page({
    data: {},
    onLoad: async function (options) {
        console.log('传过来的参数', options);
        const { requestId, backUrl, payParam } = options;
        const param = JSON.parse(decodeURIComponent(payParam));
        const pathUrl = PAGE_NAV.orderStatus;
        // 发起支付
        const flag = await platformPay(param);
        if (flag) {
            reLaunchTo(pathUrl, { requestId });
        } else {
            app.globalData.paySuccessUrl = backUrl + encodeURIComponent('?payResult=false');
            navBack();
        }
    },
})